﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Furion.CMS.Core
{
    /// <summary>
    /// 权限特性,用于标记受限的资源
    /// <para>
    /// Controller/Action 可以分别标记来进行资源访问限制
    /// </para>
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false)]
    public class PermissionOptionAttribute : Attribute
    {
        /// <summary>
        /// 权限特性
        /// </summary>
        /// <param name="name">显示名称</param>
        /// <param name="isPublic">是否公开</param>
        public PermissionOptionAttribute(string name, bool isPublic = false)
        {
            Name = name;
            IsPublic = isPublic;
        }

        /// <summary>
        /// 权限特性
        /// </summary>
        /// <param name="code">唯一代码</param>
        /// <param name="name">显示名称</param>
        /// <param name="isPublic">是否公开</param>
        public PermissionOptionAttribute(string code, string name, bool isPublic = false)
            : this(name, isPublic)
        {
            Code = code;
        }

        /// <summary>
        /// 权限代码
        /// </summary>
        public string Code { get; set; }
        /// <summary>
        /// 权限名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 是否公开
        /// </summary>
        public bool IsPublic { get; set; }
    }
}
